

from fastapi import  FastAPI
from  Config import appsetting
from fastapi.middleware.cors import CORSMiddleware
from Model.scheduler.tasks import  init_scheduler
from Controller import JobController
app = FastAPI(title='FastAPI接口文档',description='',docs_url="/", redoc_url=None)

app.include_router(JobController.router, tags=["Job 任务调度控制器"])


# 允许可以跨域的http
# origins = [
#     "http://localhost.tiangolo.com",
#     "https://localhost.tiangolo.com",
#     "http://192.168.11.97:8080",
#     "http://localhost:8080", 
# ]
origins=["*"] # 表示允许跨域
app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

app.add_event_handler("startup", init_scheduler)

if __name__ == '__main__':
    import uvicorn
    ip=appsetting.ip
    port=appsetting.port
    uvicorn.run('main:app',host=ip, port=int(port),reload=False)

#  官方 推荐 打包工具 pip install cx_Freeze
#pip3 install -i https://pypi.doubanio.com/simple -r  requirements.txt